package cn.zl.web.impl;

import cn.yunbamboos.Const;
import cn.yunbamboos.exception.AppException;
import cn.zl.common.ZLConst;
import cn.zl.mapper.StreamProxyMapper;
import cn.zl.mapper.StreamPushMapper;
import jakarta.annotation.Resource;

public class StreamService {

    @Resource
    protected StreamPushMapper streamPushMapper;
    @Resource
    protected StreamProxyMapper streamProxyMapper;

    public void checkAppAndStream(String app, String stream){
        // 判断是否使用模拟流APP
        if(ZLConst.VIRTUAL_VIDEO.APP.equals(app)){
            throw AppException.c("流应用名(virtualvideo)为模拟流应用名,不能使用");
        }
        // 查询是否存在推流
        if(streamPushMapper.existAppAndStream(app, stream)){
            throw AppException.c("应用名({})流({})已经存在推流，请修改名称", app, stream);
        }
        // 查询是否存在拉流代理
        if(streamProxyMapper.existAppAndStream(app, stream)){
            throw AppException.c("应用名({})流({})已经存在拉流代理，请修改名称", app, stream);
        }
    }
}
